TABLE.FIELD_ADD Function

Syntax

V Field_Add(C Fieldname,C Fieldtype[,N Field_Width[,N Field_Decimal[,C flags]]]])

Arguments

Fieldname

The name of the field to create.

Fieldtype

The field types, the single character codes used to represent them, and the valid parameters associated with them are:

Field Type and Type Code
Valid Parameters
Bitmap "B"

Fieldname, Field Type

Character "C"

Fieldname, Field Type, Width

Date "D"

Fieldname, Field Type

Exponent Numeric "E"

Fieldname, Field Type

Linked image "I"

Fieldname, Field Type

JPEG "J"

Fieldname, Field Type

Logical "L"

Fieldname, Field Type

Memo "M"

Fieldname, Field Type

Numeric "N"

Fieldname, Field Type, Width , Decimal Width

OLE "O"

Fieldname, Field Type

Rich text memo "R"

Fieldname, Field Type

Time "T"

Fieldname, Field Type

Short Time "Y"

Fieldname, Field Type

Field_Width

Optional. The number of characters to allocate to the field.

Field_Decimal

Optional. The number of character positions after the decimal point.

flags

Character

Description

Define the next field in a table.

Discussion

The TABLE.FIELD_ADD() method is used between the TABLE.CREATE_BEGIN() and TABLE.CREATE_END() methods to define the fields that form a table structure. The first field of the table is always defined with TABLE.CREATE_BEGIN(), subsequent fields are defined with TABLE.FIELD_ADD(). A field definition consists of at least two parameters, the Field_Name and Field_Type, and can contain up two optional parameters, Width and Decimal_Width. Field_Type is a single-character code representing one of the field types. The chosen field type determines how the optional parameters are used. If the field type is Character, an additional Width parameter is supplied, and if the field type is Numeric, the additional Width and optional Decimal_Width parameters are specified. Date, Memo, Rich text memo, Bitmap, OLE, and Logical fields are always defined with two parameters because the field widths for these field types are set automatically.

Example

Create a table.

table.create_begin("firstname","c",30)
table.field_add("lastname","c",30)
table.field_add("price","n",5,2)
table.field_add("quantity","n",2)
table.field_add("birthday","d")
'The create_end method creates the table and assign an object pointer to the table
tbl = table.create_end("sample.dbf")

See Also